//
//  myCompanyController.m
//  iOS_NongLian
//
//  Created by n369 on 16/3/3.
//  Copyright © 2016年 NongLian. All rights reserved.
//

#import "myCompanyController.h"

@interface myCompanyController () <UITableViewDataSource, UITableViewDelegate> {
    UITableView * _tableView;
    NSMutableArray * _dataSource;
    UISegmentedControl * _seg;
}

@end

@implementation myCompanyController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createNavigationBar:9];
    self.back.text = @"设置";
    [self initData];
    [self createViews];
    [self createTableView];
}

- (void)initData {
    _dataSource = [[NSMutableArray alloc] initWithArray:@[@"", @"", @"", @""]];
}

- (void)createTableView {
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 118, ScreenWidth, ScreenHeight - 118)];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.rowHeight = 100;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [self.view addSubview:[Factory createViewWithBackgroundColor:RGB(216, 216, 216) frame:CGRectMake(0, 118, ScreenWidth, 0.5)]];
}

- (void)createViews {
    _seg = [[UISegmentedControl alloc] initWithItems:@[@"产品", @"新闻", @"经验", @"视频"]];
    _seg.frame = CGRectMake(35, 75, ScreenWidth - 70, 30);
    _seg.selectedSegmentIndex = 0;
    _seg.tintColor = ColorNavigation;
    [_seg addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_seg];
}

- (void)segAction:(UISegmentedControl *)seg {
    [_tableView reloadData];
}

#pragma mark tableViewDatasource&Delegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //    return 3;
    return _dataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    if (_seg.selectedSegmentIndex == 0) {
//        GoodCell * goodCell = [tableView dequeueReusableCellWithIdentifier:@"goodCell"];
//        if (!goodCell) {
//            goodCell = [[[NSBundle mainBundle] loadNibNamed:@"GoodCell" owner:self options:nil] lastObject];
//        }
//        return goodCell;
//        
//    }
//    TrendsCell * trendCell = [tableView dequeueReusableCellWithIdentifier:@"trendCell"];
//    if (!trendCell) {
//        trendCell = [[[NSBundle mainBundle] loadNibNamed:@"TrendsCell" owner:self options:nil] lastObject];
//    }
//    return trendCell;
    UITableViewCell * table = [[UITableViewCell alloc] init];
    return table;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%ld", indexPath.row);
}

- (void)backTitleAction {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
